d_global_debug = 0;

X_INIT = false;X_Server = false; X_Client = false; X_JIP = false;X_SPE = false;X_MP = isMultiplayer;
X_LOADED = false;
X_PLAYER_INIT = false;

call compile preprocessFileLineNumbers "base\functions.sqf";
call compile preprocessFileLineNumbers "base\common\editorfunctions.sqf";
call compile preprocessFileLineNumbers "base\common\commonfunctions.sqf";
call compile preprocessFileLineNumbers "base\common\hash_array.sqf";
call compile preprocessFileLineNumbers "base\common\netfunctions.sqf";
call compile PreProcessFileLineNumbers "base\common\building_position.sqf";
call compile preprocessFileLineNumbers "base\client\player_functions.sqf";
call compile preprocessFileLineNumbers "base\client\clientfunctions.sqf";
call compile PreProcessFileLineNumbers "base\mission\mission_functions.sqf";
call compile PreProcessFileLineNumbers "base\server\R3F_FNCT_ied.sqf";
call compile PreProcessFileLineNumbers "base\server\serverfunctions.sqf";
call compile PreProcessFileLineNumbers "base\server\artillery.sqf";

diag_log "all functions compiled";

#define __waitpl [] spawn {waitUntil {!isNull player};X_INIT = true}
if (isServer) then {
	X_Server = true;
	if (!isDedicated) then {
		X_Client = true;
		X_SPE = true;
		__waitpl;
	} else {
		X_INIT = true;
	};
} else {
	X_Client = true;
	if (isNull player) then {
		X_JIP = true;
		__waitpl;
	} else {
		X_INIT = true;
	};
};

enableTeamSwitch d_enable_teamswitch;
enableSaving [false, false];

if ( ((getMarkerPos "R3F_DEBUG") distance [0,0,0]) > 10) then {
	execVM "base\debug\scripts\functions_R3F_Debug.sqf";
	d_mission_debug_messages = true;
};

#include "i_common.sqf";
execVM "base\client\briefing.sqf";
if (X_SERVER) then {
	#include "i_server.sqf";
};

if (X_CLIENT) then {
	#include "i_client.sqf";
};
execVM "base\revive_init.sqf";
X_LOADED = true;
